package com.dk.op;

import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class OptionalTest {
    public static void main(String[] args) {
        String s = "kjgjkbjbkj";
        Optional<String> op = Optional.ofNullable(s);
        String s1 = op.orElseGet(() -> "默认值");
        System.out.println(s1.length());

        Consumer<String> c = ss->System.out.println(ss.length());
        op.ifPresent(ss->System.out.println(ss.length()));
    }

}
